def is_valid_parentheses(exp):
    stack = []
    for ch in exp:
        if ch == '(':
            stack.append(ch)
        elif ch == ')':
            if not stack:
                return 0
            stack.pop()
    return 1 if not stack else 0

if __name__ == "__main__":
    exp = input().strip()
    result = is_valid_parentheses(exp)
    print(result)
